package lhdx4;

import java.util.Scanner;

public class Xueshechazyin {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Xueshechaz java78 = new Xueshechaz();
        java78.name = "牛x的java78";
        java78.dirTeacher = "Old Liu";
        int choice = 0;
        while (true) {
            System.out.println("1:加新生,2:查看信息，3:按照位置查找,4：按照学生名查找，5:修改学生名，6:班级人数,8：退出");
            choice = in.nextInt();
            if (choice == 1) {
                System.out.print("请输入新生的姓名：");
                String sname = in.next();
                java78.add(sname);
            } else if (choice == 2) {
                java78.showInformation();
            }else if (choice==3){
                int index=in.nextInt();
                System.out.println(java78.find(index));
            } else if (choice == 4) {
                System.out.print("找谁：");
                String name = in.next();
                boolean exists = java78.searchName(name);
                if (exists) {
                    System.out.println(name + "在这个班");
                } else {
                    System.out.println(name + "不在这个班");
                }
            }else if (choice==5){
                System.out.print("修改哪个学生姓名：");
                String oldName=in.next();
                System.out.print("修改后的名字：");
                String newName=in.next();
                boolean exist=java78.update(oldName,newName );
                if (exist){
                    System.out.println("已修改成："+newName);
                }else {
                    System.out.println(oldName+"该名字不存在");
                }
            }else if(choice==6){
               int b= java78.getNum();
                System.out.println("班级人数:"+b+"个");

            } else if (choice == 8) {
                break;
            }
        }
    }
}
